package com.unionpay.upyzt.model;

import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.net.APIResource;
import com.unionpay.upyzt.net.RequestOptions;
import com.unionpay.upyzt.resp.MediaResp;
import lombok.experimental.Accessors;

import java.io.File;

@Accessors(chain = true)
public class Media extends APIResource {

    /**
     * 图片上传
     *
     * @param file 图片文件
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MediaResp uploadImage(File file) throws UpyztException {
        return uploadImage(file, null);
    }

    /**
     * 图片上传
     *
     * @param file    图片文件
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MediaResp uploadImage(File file, RequestOptions options) throws UpyztException {
        return APIResource.uploadFile(RequestMethod.POST, singleClassURL(Media.class) + "/images", file, MediaResp.class, options);
    }

}
